<title>资金明细</title>
<div class="layui-fluid">
    <div class="layui-card">
        <script type="text/html" id="financial-balance-index-toolbar_tmp">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm" lay-event="financial-balance-index-withdraw">申请提现</button>
            </div>
        </script>
        <div class="layui-card-body">
            <table id="financial-balance-detail-index" lay-filter="financial-balance-index"></table>
        </div>
    </div>
</div>
<script>
    layui.use(['common', 'admin', 'table'], function () {
        var common = layui.common,
            admin = layui.admin,
            view = layui.view,
            table = layui.table,
            lay_id_prefix = 'financial-balance-index',//当前页id前缀
            edit_id_prefix = 'financial-balance-withdraw',//添加编辑页id前缀
            edit_view_url = 'financial/balance/withdraw',//添加编辑页模板地址
            api_action_url = layui.setter.apiHost + '/financial/balance';

        //表格操作
        table.render({
            elem: '#financial-balance-detail-index',
            url: api_action_url,
            toolbar: '#' + lay_id_prefix + '-toolbar_tmp',
            cols: [[
                {field: 'id', title: 'ID', width: 80},
                {field: 'amount', title: '金额', width: 100},
                {field: 'balance', title: '账户余额', width: 100},
                {field: 'event', title: '类型', width: 120},
                {field: 'detail_no', title: '单号', width: 200},
                {field: 'note', title: '备注'},
                {field: 'created_at', title: '时间', width: 170},
            ]],
            page: true
        });

        //头部工具栏操作
        table.on('toolbar(' + lay_id_prefix + ')', function (obj) {
            var type = obj.event;
            switch (type) {
                case lay_id_prefix + '-withdraw':
                    common.open_window('添加', api_action_url, edit_view_url, edit_id_prefix, {id: 1});
                    break;
            }
        });
    });
</script>
